import React, { Component } from 'react'

export default class Input extends Component {
  state = {
    ipt:'初始'
  }
  changeIpt = (ev) => {
    console.log(ev.target.value);
    this.setState({
      ipt:ev.target.value
    })
 }
  render() {
    const { ipt } = this.state
    return (
      <div>
        {/* value={ipt} onChange={ this.changeIpt}搭配onchange事件一起写 */}
        <input type="text" value={ipt} onChange={ this.changeIpt} />
        <p>
          {ipt}
        </p>
        {/* 先不加括号调用会报错 */}
        {/* <button onClick = {this.changeIpt}>点我</button> */}
      </div>
    )
  }
}
